package com.shipwe.loans.ui.adapter

import android.view.View
import androidx.recyclerview.widget.RecyclerView
import com.shipwe.adapter.ShipweRecyclerViewAdapter
import com.shipwe.adapter.ShipweViewHolderHelper
import com.shipwe.loans.R
import org.json.JSONObject

/**
 * Shipwe
 * @Author wwdeng
 * @CreateTime: 2024/11/18 16:42
 * @Annotation：客服适配器
 */
class CustomerAdapter(recyclerView: RecyclerView?) : ShipweRecyclerViewAdapter<JSONObject>(recyclerView, R.layout.dialog_customer_item) {
    override fun setItemChildListener(helper: ShipweViewHolderHelper, viewType: Int) {
        helper.setItemChildClickListener(R.id.customerFun) //拨号、复制
    }

    override fun fillData(helper: ShipweViewHolderHelper, position: Int, model: JSONObject) {
        helper.setText(R.id.customerTypeValue,model.optString("value"))
        val imgType = helper.getImageView(R.id.customerFunIcon)
        val type = model.optString("type")
        when(type){
            "MOBILE" -> {//电话
                helper.setText(R.id.customerTypeTitle,mContext.getString(R.string.customer_mobile_title))
                helper.setText(R.id.customerFunText,mContext.getString(R.string.customer_mobile_dial))
                imgType.setImageResource(R.drawable.customer_mobile_call)
                helper.setVisibility(R.id.customerMobileTipView, View.VISIBLE)
            }
            else -> {//邮箱
                helper.setText(R.id.customerTypeTitle,mContext.getString(R.string.customer_email_title))
                helper.setText(R.id.customerFunText,mContext.getString(R.string.customer_email_copy))
                imgType.setImageResource(R.drawable.customer_email_copy)
                helper.setVisibility(R.id.customerMobileTipView, View.GONE)
            }
        }
    }
}